package com.example.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

/**
 * @className: LoggerController
 * @author: 芃
 * @description:
 * @date: 2024/12/23 17:30
 */
@RestController
public class LoggerController {

    private static Logger logger = LoggerFactory.getLogger(LoggerController.class);

    @PostConstruct
    public void init() {
        System.out.println("打印日志");

        logger.error("发生错误");
        logger.warn("发生警告");
        logger.info("打印信息");//->Spring的默认日志级别，下面两个级别不打印~
        logger.debug("调试信息");
        logger.trace("跟踪信息");
    }
}
